package hos.controller;

import java.util.Scanner;

import hos.po.P_information;
import hos.service.P_informationSerivceImp;
import hos.service.P_informationService;
import hos.service.StaffServiceImp;

public class P_informationController {
	public void P_infoCreate() {
		//患者输入注册信息
		System.out.println("请输入患者相关信息");
		P_information P1 = new P_information();
		Scanner scan = new Scanner(System.in);
		System.out.println("请输入患者编号");
		P1.setP_id(scan.next());
		System.out.println("请输入患者姓名");
		P1.setP_name(scan.next());
		System.out.println("请输入患者电话");
		P1.setP_tel(scan.next());
		System.out.println("请输入患者性别（男性：1；女性：0）");
		P1.setP_gender(scan.nextInt());
		System.out.println("请输入患者年龄");
		P1.setP_age(scan.nextInt());
		System.out.println("请输入患者身份证号");
		P1.setP_idcard(scan.next());
		System.out.println("请输入患者登录密码");
		P1.setP_pwd(scan.next());
		P_informationService p_infoSerivce = new P_informationSerivceImp();
		String res = p_infoSerivce.P_infoAutoLogin(P1);
		System.out.println(res);
		//scan.close();
		
	}
	
	
	public void P_infoDelte() {
		System.out.println("请输入要删除的患者的账号(id)");
		Scanner scan = new Scanner(System.in);
		String id = scan.next();
		P_informationSerivceImp p_infoService = new P_informationSerivceImp();
		String res = p_infoService.P_infoDelete(id);
		System.out.println(res);
		//scan.close();
	}
	
	
	public void P_infoSelect() {
		System.out.println("请输入要查找的患者的姓名");
		Scanner scan = new Scanner(System.in);
		String name = scan.next();
		P_informationSerivceImp p_infoService = new P_informationSerivceImp();
		String res[][] = p_infoService.P_infoSelect(name);
		for(String[] i : res) {
			for(String j : i) {
				System.out.print(j+" ");
			}
			System.out.println();
		}
		//scan.close();
	}
	
	
	public void P_infoChange() {
		System.out.println("请输入要修改的患者的id");
		Scanner scan = new Scanner(System.in);
		String id = scan.next();
		System.out.println("请输入要修改的列名（id,name,tel,gender,age,idcard）");
		String colunm = "p_"+scan.next();
		System.out.println("请输入修改的内容");
		String value = scan.next();
		P_informationSerivceImp p_infoService = new P_informationSerivceImp();
		String res = p_infoService.P_infoChange(id, colunm, value);
		System.out.println(res);
		//scan.close();
	}
	
	//登录成功后返回患者对象
	public P_information P_infoLoad() {
		System.out.println("---------------------------");
		System.out.println("患者登录");
		System.out.println("请输入账号");
		Scanner scan = new Scanner(System.in);
		String id = scan.next();
		System.out.println("请输入密码");
		String pwd = scan.next();
		//scan.close();
		P_informationSerivceImp p_infoSeriveImp = new P_informationSerivceImp();
		P_information p_exist = p_infoSeriveImp.P_infoLoad(id, pwd);
		if(p_exist == null) {
			System.out.print("请输入正确的账号密码");
		}else {
			System.out.print("登录成功！");
			return p_exist;
		}
		return null;
	}
}
